import helper
import time
from data import ClientState

interval = 3  # 检查间隔
isShowHurtList = False  # 是否显示过了伤害列表

while True:

    state = helper.getCurrClientState() # 获取当前客户端的状态

    if state == ClientState.NoneState:
        pass
    elif state == ClientState.OnQueue:  # 队列中
        isShowHurtList = False
        result = helper.findPic(r'images\accept-btn.jpg')

        if result is not None:
            x = int(result['result'][0])
            y = int(result['result'][1])
            helper.click(x, y)
            print("鼠标已经点击")
        else:
            print("没找到对局")
    elif state == ClientState.OnOverList:  # 结束页面

        if not isShowHurtList:
            result = helper.findPic(r'images\advanced-data.jpg')
            if result is not None:
                x = int(result['result'][0])
                y = int(result['result'][1])
                helper.click(x, y)

            time.sleep(2)

            result = helper.findPic(r'images\chart.jpg')
            if result is not None:
                x = int(result['result'][0])
                y = int(result['result'][1])
                helper.click(x, y)
                print("已经帮您打开伤害列表")
                isShowHurtList = True  # 已经显示过伤害列表了

    time.sleep(interval)
